# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.BinaryAuthorization.V1.Model.Check do
  @moduledoc """
  A single check to perform against a Pod. Checks are grouped into `CheckSet` objects, which are defined by the top-level policy.

  ## Attributes

  *   `alwaysDeny` (*type:* `boolean()`, *default:* `nil`) - Optional. A special-case check that always denies. Note that this still only applies when the scope of the `CheckSet` applies and the image isn't exempted by an image allowlist. This check is primarily useful for testing, or to set the default behavior for all unmatched scopes to "deny".
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - Optional. A user-provided name for this check. This field has no effect on the policy evaluation behavior except to improve readability of messages in evaluation results.
  *   `imageAllowlist` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.ImageAllowlist.t`, *default:* `nil`) - Optional. Images exempted from this check. If any of the patterns match the image url, the check will not be evaluated.
  *   `imageFreshnessCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.ImageFreshnessCheck.t`, *default:* `nil`) - Optional. Require that an image is no older than a configured expiration time. Image age is determined by its upload time.
  *   `sigstoreSignatureCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.SigstoreSignatureCheck.t`, *default:* `nil`) - Optional. Require that an image was signed by Cosign with a trusted key. This check requires that both the image and signature are stored in Artifact Registry.
  *   `simpleSigningAttestationCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.SimpleSigningAttestationCheck.t`, *default:* `nil`) - Optional. Require a SimpleSigning-type attestation for every image in the deployment.
  *   `slsaCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.SlsaCheck.t`, *default:* `nil`) - Optional. Require that an image was built by a trusted builder (such as Google Cloud Build), meets requirements for Supply chain Levels for Software Artifacts (SLSA), and was built from a trusted source code repostitory.
  *   `trustedDirectoryCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.TrustedDirectoryCheck.t`, *default:* `nil`) - Optional. Require that an image lives in a trusted directory.
  *   `vulnerabilityCheck` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.VulnerabilityCheck.t`, *default:* `nil`) - Optional. Require that an image does not contain vulnerabilities that violate the configured rules, such as based on severity levels.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :alwaysDeny => boolean() | nil,
          :displayName => String.t() | nil,
          :imageAllowlist => GoogleApi.BinaryAuthorization.V1.Model.ImageAllowlist.t() | nil,
          :imageFreshnessCheck =>
            GoogleApi.BinaryAuthorization.V1.Model.ImageFreshnessCheck.t() | nil,
          :sigstoreSignatureCheck =>
            GoogleApi.BinaryAuthorization.V1.Model.SigstoreSignatureCheck.t() | nil,
          :simpleSigningAttestationCheck =>
            GoogleApi.BinaryAuthorization.V1.Model.SimpleSigningAttestationCheck.t() | nil,
          :slsaCheck => GoogleApi.BinaryAuthorization.V1.Model.SlsaCheck.t() | nil,
          :trustedDirectoryCheck =>
            GoogleApi.BinaryAuthorization.V1.Model.TrustedDirectoryCheck.t() | nil,
          :vulnerabilityCheck =>
            GoogleApi.BinaryAuthorization.V1.Model.VulnerabilityCheck.t() | nil
        }

  field(:alwaysDeny)
  field(:displayName)
  field(:imageAllowlist, as: GoogleApi.BinaryAuthorization.V1.Model.ImageAllowlist)
  field(:imageFreshnessCheck, as: GoogleApi.BinaryAuthorization.V1.Model.ImageFreshnessCheck)

  field(:sigstoreSignatureCheck, as: GoogleApi.BinaryAuthorization.V1.Model.SigstoreSignatureCheck)

  field(:simpleSigningAttestationCheck,
    as: GoogleApi.BinaryAuthorization.V1.Model.SimpleSigningAttestationCheck
  )

  field(:slsaCheck, as: GoogleApi.BinaryAuthorization.V1.Model.SlsaCheck)
  field(:trustedDirectoryCheck, as: GoogleApi.BinaryAuthorization.V1.Model.TrustedDirectoryCheck)
  field(:vulnerabilityCheck, as: GoogleApi.BinaryAuthorization.V1.Model.VulnerabilityCheck)
end

defimpl Poison.Decoder, for: GoogleApi.BinaryAuthorization.V1.Model.Check do
  def decode(value, options) do
    GoogleApi.BinaryAuthorization.V1.Model.Check.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.BinaryAuthorization.V1.Model.Check do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
